# 905 简单：按奇偶排序数组
from collections import deque


def sortArrayByParity(nums):
    ret = deque()
    for num in nums:
        if num % 2:
            ret.append(num)
        else:
            ret.appendleft(num)

    return list(ret)


print(sortArrayByParity([3,1,2,4]))
